import {t, api, message, bs} from "@/service/index.js"


export default {
    url: {
        find: "/role/find",
        edit: "/role/edit",
        del: "/role/del"
    },
    find(data) {
        return api.post(this.url.find,data);
    },
    edit(data,tree){
        if(tree.length <= 0){
            message.warning(t("role.noMenu"))
            return
        }
        const d = Object.assign({},data)
        delete d.rules
        d.menuIds = tree.map(item => item.id)
        return api.post(this.url.edit,d).then(res => {
            message.success(t("btn.success"))
            return true
        }).catch(e => {
            return false
        })
    },
    del(data){
        return api.post(this.url.del,data).then(res => {
            message.success(t("btn.success"))
            return true
        }).catch(e => {
            return false
        })
    }
}